const CourseTabModel = require('../db/models/courseTab');

class CourseTabService {
    async addCourseTabData (data) {
        const cid = data.cid;
        
        const result = await CourseTabModel.findOne({
            wherr: { cid }
        })

        if (result) {
            return await CourseTabModel.update(data, {
                where: { cid }
            })
        } else {
            return await CourseTabModel.create(data);
        }
    }

    async getCourseFieldData () {
        return await CourseTabModel.findAll({
            attributes: {
                exclude: ['cid']
            }
        });
    }
}

module.exports = new CourseTabService();